import request from '@/utils/request'

const api_prefix = '/admin/hardware/equipment'

export default {

  /**
   * 修改设备状态
   *
   * @param id
   * @param status
   */
  changeEquipmentStatus(id, status) {
    return request(({
      url: `${api_prefix}/status`,
      method: 'get',
      params: { id, status }
    }))
  },

  /**
   * 创建设备
   *
   * @param equipment
   */
  addEquipment(equipment) {
    return request(({
      url: `${api_prefix}/add`,
      method: 'post',
      data: equipment
    }))
  },

  /**
   * 删除设备
   *
   * @param id
   */
  deleteEquipment(id) {
    return request(({
      url: `${api_prefix}/delete`,
      method: 'get',
      params: { id }
    }))
  },

  /**
   * 批量删除设备
   *
   * @param idList
   */
  batchDeleteEquipment(idList) {
    return request(({
      url: `${api_prefix}/delete/batch`,
      method: 'post',
      data: idList
    }))
  },

  /**
   * 更新设备
   *
   * @param equipment
   */
  updateEquipment(equipment) {
    return request(({
      url: `${api_prefix}/update`,
      method: 'post',
      data: equipment
    }))
  },

  /**
   * 根据 id 获取设备
   *
   * @param id
   */
  getEquipmentById(id) {
    return request(({
      url: `${api_prefix}/get`,
      method: 'get',
      params: { id }
    }))
  },

  /**
   * 获取设备列表
   */
  listEquipment() {
    return request(({
      url: `${api_prefix}/list`,
      method: 'get'
    }))
  },

  /**
   * 分页获取设备数据列表
   *
   * @param queryParams 条件参数
   * @returns {*}
   */
  listEquipmentByPage(queryParams) {
    return request(({
      url: `${api_prefix}/list/page`,
      method: 'get',
      params: queryParams
    }))
  }

}
